<!DOCTYPE html>
<html>
<head>
    <title>Circular Motion Diagram</title>
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
        }
        canvas {
            border: 1px solid #d3d3d3;
        }
    </style>
</head>
<body>
<canvas id="physicsCanvas" width="500" height="400"></canvas>
<script>
    const canvas = document.getElementById('physicsCanvas');
    const ctx = canvas.getContext('2d');

    // Define coordinates and dimensions
    const cx = canvas.width / 2;
    const cy = 190;
    const diskRadiusX = 160;
    const diskRadiusY = 45;
    const r1_screen = 70;
    const r2_screen = 110;
    const massRadius = 7;
    const x1 = cx - r1_screen;
    const x2 = cx + r2_screen;

    // --- Draw the Diagram ---

    // 1. Draw the disk
    ctx.beginPath();
    ctx.ellipse(cx, cy, diskRadiusX, diskRadiusY, 0, 0, 2 * Math.PI);
    // Create a subtle texture using a radial gradient for a better look
    const gradient = ctx.createRadialGradient(cx, cy, 5, cx, cy, diskRadiusX);
    gradient.addColorStop(0, '#E8E8E8');
    gradient.addColorStop(1, '#D0D0D0');
    ctx.fillStyle = gradient;
    ctx.fill();
    ctx.strokeStyle = 'black';
    ctx.lineWidth = 1.5;
    ctx.stroke();

    // 2. Draw the axis of rotation
    ctx.beginPath();
    ctx.moveTo(cx, cy - diskRadiusY - 80);
    ctx.lineTo(cx, cy + diskRadiusY + 80);
    ctx.stroke();

    // 3. Draw the angular velocity arrow (ω)
    // Draw the curved arrow line
    ctx.beginPath();
    // Use an arc to create the curved arrow part
    ctx.arc(cx, cy - 80, 28, Math.PI * 1.1, Math.PI * 1.9);
    ctx.stroke();

    // Draw the arrowhead at the start of the arc (left side)
    const arrowAngle = Math.PI * 1.9;
    const arrowX = cx + 28 * Math.cos(arrowAngle);
    const arrowY = cy - 80 + 28 * Math.sin(arrowAngle);
    ctx.beginPath();
    ctx.moveTo(arrowX, arrowY);
    ctx.lineTo(arrowX + 10, arrowY - 2);
    ctx.moveTo(arrowX, arrowY);
    ctx.lineTo(arrowX + 4, arrowY + 9);
    ctx.stroke();
    
    // Draw the 'ω' symbol
    ctx.font = 'italic 24px Times New Roman';
    ctx.fillStyle = 'black';
    ctx.textAlign = 'left';
    ctx.textBaseline = 'middle';
    ctx.fillText('ω', cx + 40, cy - 80);

    // 4. Draw masses and connecting line
    // Center point
    ctx.beginPath();
    ctx.arc(cx, cy, 3, 0, 2 * Math.PI);
    ctx.fillStyle = 'black';
    ctx.fill();

    // Connecting line
    ctx.beginPath();
    ctx.moveTo(x1, cy);
    ctx.lineTo(x2, cy);
    ctx.stroke();

    // Mass m1
    ctx.beginPath();
    ctx.arc(x1, cy, massRadius, 0, 2 * Math.PI);
    ctx.fill();

    // Mass m2
    ctx.beginPath();
    ctx.arc(x2, cy, massRadius, 0, 2 * Math.PI);
    ctx.fill();

    // 5. Add labels
    ctx.textAlign = 'center';
    
    // Label m1
    ctx.font = 'italic 22px Times New Roman';
    ctx.fillText('m', x1 - 2, cy - 25);
    ctx.font = 'italic 16px Times New Roman';
    ctx.fillText('1', x1 + 8, cy - 20);

    // Label m2
    ctx.font = 'italic 22px Times New Roman';
    ctx.fillText('m', x2 + 2, cy - 25);
    ctx.font = 'italic 16px Times New Roman';
    ctx.fillText('2', x2 + 12, cy - 20);

    // Label r1
    ctx.font = 'italic 22px Times New Roman';
    ctx.fillText('r', (x1 + cx) / 2, cy + 18);
    ctx.font = 'italic 16px Times New Roman';
    ctx.fillText('1', (x1 + cx) / 2 + 8, cy + 23);

    // Label r2
    ctx.font = 'italic 22px Times New Roman';
    ctx.fillText('r', (cx + x2) / 2, cy + 18);
    ctx.font = 'italic 16px Times New Roman';
    ctx.fillText('2', (cx + x2) / 2 + 8, cy + 23);

    // 6. Draw the caption
    ctx.font = '22px SimHei'; // Standard Chinese font
    ctx.textAlign = 'center';
    ctx.textBaseline = 'bottom';
    ctx.fillText('习题 1-34 图', cx, canvas.height - 15);

</script>
</body>
</html>